package priv.pront.code.mati.national.practice;

import java.util.Scanner;

/**
 * @Author: Pronting
 * @Description: TODO
 * @DateTime: 2023/12/1 13:34
 **/
public class P2615_神奇的幻方 {

    static int n;
    static int[][] a;
    static int[] x, y;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        a = new int[n][n];
        x = new int[n * n];
        y = new int[n * n];
        a[0][n / 2] = 1;
        x[0] = 0;
        y[0] = n / 2;
        for (int k = 1; k < n * n; k++) {
            if(x[k - 1] == 0 && y[k - 1] != n - 1) {
                x[k] = n -1; y[k] = y[k - 1] + 1;
            }else if(x[k - 1] != 0 && y[k - 1] == n - 1){
                x[k] = x[k - 1] - 1; y[k] = 0;
            }else if(x[k - 1] == 0 && y[k - 1] == n - 1){
                x[k] = x[k - 1] + 1; y[k] = y[k - 1];
            }else{
                if(a[x[k - 1] - 1][y[k - 1] + 1] == 0){
                    x[k] = x[k - 1] - 1; y[k] = y[k - 1] + 1;
                }else{
                    x[k] = x[k - 1] + 1; y[k] = y[k - 1];
                }
            }
                a[x[k]][y[k]] = k + 1;
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                System.out.print(a[i][j] + " ");
            }
            System.out.println();
        }

    }
}
